package com.visionet.waveletData.web.repository.plan;

import com.visionet.waveletData.web.entity.plan.PlayPlan;
import com.visionet.waveletData.web.vo.plan.PlayPlanVo;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public interface PlayPlanDao extends PagingAndSortingRepository<PlayPlan, Long>, JpaSpecificationExecutor<PlayPlan>{

	@Query("select u from PlayPlan u where u.id=?1 ")
	PlayPlan findPlayPlanById(Long id);

	@Query(" from PlayPlan ")
	List<PlayPlan> findAll();

	@Query("from PlayPlan p where p.planName=?1 and p.companyId = ?2 and p.is_deleted='0' ")
	List<PlayPlan> findByPlanNameAndCompanyId(String planName,String planId);

	@Query("from PlayPlan p where p.planName=?1 and p.id !=?2 and p.is_deleted='0' ")
	List<PlayPlan> findByPlanNameAndPlanId(String planName,Long planId);

	public PageImpl<PlayPlanVo> findPagePlayPlan(PlayPlanVo playPlanVo, Pageable page);

	@Query(" from PlayPlan where company_id = ? and is_deleted = '0'")
	List<PlayPlan> findAllByCompanyId(String companyId);

	public List<PlayPlan> findAllPlanIdByUpdateDate(Date lastUpdateDate,Pageable pageable);

}
